feat: default-on decision-level logging with configurable logLevel - #332
Merged
Conversation
- LogLevel (debug|info|warn|error|silent) with rank-gated file writes; constructor keeps boolean-only back-compat (false→warn, true→debug) - new logLevel config (default "info") — decision events written by default; debug:true overrides to full debug + per-request snapshots - INFO audit trail on core paths: plugin init, per-request transform summary, mid-session model switch, nudge inject/suppress decisions (tier triggers, usage %, growth floor, recommended ranges), auto-update check lifecycle - 4 new logger level-semantics tests; docs/schema updated
📦 Built Plugin ArtifactBranch: Option A — Install from npm PR tag (recommended)opencode plugin opencode-acp@pr-332 --globalEach push to this PR publishes a new version under the Option B — Install from GitHubopencode plugin "github:ranxianglei/opencode-acp#2026-08-21_default-on-logging" --globalOption C — Download artifact
tar xzf opencode-acp-pr332.tgz
cp -r package/dist ~/.cache/opencode/packages/opencode-acp@latest/node_modules/opencode-acp/dist
This comment is automatically updated on each push. |
- invalid explicit level (e.g. typo 'verbose') fell through to LEVEL_RANK[undefined], failing every gate and dropping even ERROR/WARN; config validation is warn-only so bad values do reach the constructor. Now clamps to the legacy boolean mapping (false→warn, true→debug). - info()/debug() early-return before getCallerFile so warn/error/silent users no longer pay Error().stack capture for lines that get dropped. - regression test: bad level + error() must still write 1 line.
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Default configuration (
debug: false) wrote only WARN/ERROR to~/.config/opencode/logs/acp/daily/<date>.log. INFO/DEBUG requireddebug: true, so a default install left almost no decision trail for diagnosing nudge/compression/update behavior.Fix
Default-on INFO: decision-level events now land in the daily log out of the box.
Logger core (
lib/logger.ts)LogLevel = "debug" | "info" | "warn" | "error" | "silent"+ rank-gated writes (silentswallows everything).constructor(enabled: boolean, level?: LogLevel);level ?? (enabled ? "debug" : "warn")— boolean-only callers keep exact old semantics (~40 test files untouched).get enabled()becomes a derived view (level === "debug");saveContextsnapshots remain debug-only (no per-request JSON dumps by default).Config
logLeveloption (default"info"), validated against the 5-value enum, indcp.schema.json+ merged per-layer.debug: trueoverrides to full debug as before.INFO audit trail on core paths
index.ts): version / workspace / resolved level / secure mode / auto-update.lib/hooks.ts): transform summary — model, message count, pre/post tokens, context usage %, nudged; mid-session model switch.lib/messages/inject/inject.ts): injection (trigger tier, usage %, growth vs floor, recommended ranges), emergency/compactnotice, suppression reasons (all_protected/in_protected_zone/below_effective_floor), tier-trigger injection.lib/update.ts): optional Logger threaded through; full check lifecycle (start, every skip reason, new version found, applied, failed).Tests & docs
tests/logger.test.ts(explicit info gates debug; silent swallows errors; error level;enabledgetter). 8/8 logger tests, 1028/1028 full suite, tsc 0 errors.logLevelsection + rewrittendebugsection), README×2 config examples, devlog2026-08-21_default-on-logging/.Behavior matrix
logLevel: "warn"logLevel: "debug"logLevel: "silent"debug: trueChecklist
tsc --noEmit— 0 errorsnew Logger(false)tests unchanged and passing